package com.stupro.cjlu.bo;

import com.stupro.cjlu.constant.UserType;
import lombok.Data;

import java.io.Serializable;

@Data
public class LoginStatusBO implements Serializable {
    //判断是否已经登录
    private Boolean loggedIn = false;
    //用户ID
    private Integer userId;
    //用户账号
    private String username;
    //用户类型（登录方式） 初始化为0
    private Integer userType = UserType.NO;
    //权限
    private Integer permission = 0;

    //获取登录状态中的用户ID，用户账号，用户类型，权限
    public static LoginStatusBO fromUserInfo(UserInfoBO userInfoBO) {
        LoginStatusBO loginStatus = new LoginStatusBO();
        loginStatus.loggedIn = true;
        loginStatus.userId = userInfoBO.getId();
        loginStatus.username = userInfoBO.getUsername();
        loginStatus.userType = userInfoBO.getUserType();
        loginStatus.permission = userInfoBO.getPermission();

        return loginStatus;
    }
}
